<template>
    <div v-if="goodsInfo !== undefined && goodsInfo.columns !== undefined && goodsInfo.services !== undefined"
         class="base-info">
         <!-- 标题 -->
      <div class="info-title">{{goodsInfo.title}}</div>
      <!-- 价格 -->
      <div class="info-price">
        <span class="n-price">{{goodsInfo.newPrice}}</span>
        <span class="o-price">{{goodsInfo.oldPrice}}</span>
        <span v-if="goodsInfo.discount" class="discount">{{goodsInfo.discount}}</span>
      </div>
      
      <div class="info-other" v-if="goodsInfo.columns[0]">
        <span>{{goodsInfo.columns[0]}}</span>
        <span>{{goodsInfo.columns[1]}}</span>
        <span>{{goodsInfo.services[goodsInfo.services.length - 1].name}}</span>
      </div>
      <div class="info-service">
        <span class="info-service-item"
              v-for="index in goodsInfo.services.length-1" :key="index">
          <img v-if="goodsInfo.services[index-1].icon !== undefined" :src="goodsInfo.services[index-1].icon" alt="">
          <span>{{goodsInfo.services[index-1].name}}</span>
        </span>
      </div>
    </div>
  </template>
  
  <script>
  export default {
    name: 'DetailBaseInfo',
    props: {
      goodsInfo: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    
  }
  </script>
  
  <style scoped>
  .base-info {
    margin:0 10px ;
  }
  .info-title {
    margin: 10px 0 10px;
    text-indent: 2em;
    color: #000;
    font-weight: 500;
  }
  .n-price {
    color: var(--color-high-text);
    font-size: 20px;
    padding-right: 5px;
  }
  .o-price {
    text-decoration: line-through;
    font-size: 14px;
  }
  .discount {
    position: relative;
    top: -5px;
    left: 5px;
    padding:3px 10px;
    border-radius: 8px;
    background-color: var(--color-high-text);
    color: #fff;
  }
  .info-other {
    padding: 20px 0 10px;
    display: flex;
    font-size: 12px;
    color: #ccc;
    border-bottom: 1px solid rgba(100,100,100,.1);
  }
  .info-other span {
    flex: 1;
  }
  .info-service {
    display: flex;
    justify-content: space-between;
    line-height: 60px;
  
  }
  .info-service-item img {
    width: 14px;
    height: 14px;
    position: relative;
    top: 2px;
  }
  .info-service-item span {
    font-size: 13px;
    color: #333;
  }
  
  </style>